package main

import (
	"flag"
	"fmt"
	"net/http"
)

var dir string
var port int

func main() {

	flag.StringVar(&dir, "dir", "./", "fileserver dir")
	flag.IntVar(&port, "port", 8000, "fileserver listen port")

	flag.Parse()

	// curDir, _ := os.Getwd()
	http.Handle("/", http.FileServer(http.Dir(dir)))
	addr := fmt.Sprintf(":%d", port)
	fmt.Println("listen ", addr)
	err := http.ListenAndServe(addr, nil)
	if err != nil {
		fmt.Println("errmsg=", err)
	}
}
